<template>
  <el-card class="box-card">
    <i class=" el-icon-video-camera-solid"></i>
    <span style="margin-left: 10px">疫情概括</span>
    <ul>
      <li v-for="item in zone" :key="item.index">
          <span style="margin-left:20px;font-size: 14px;color: #919499">{{item.index+1}}  {{item.tsxx}}</span>
      </li>
    </ul>
    <el-divider></el-divider>
    <ul>
      <li v-for="item in newList1" :key="item.title">
        <span style="margin-left:20px;font-size: 14px;color: #919499">{{item.title}}</span>
      </li>
    </ul>
  </el-card>
</template>

<script>
export default {
  data () {
    return {
      dataList: [],
      zone: [],
      newsList: [],
      newList1: []
    }
  },
  created () {
    this.yqdt()
    this.ssxx()
  },
  methods: {
    yqdt () {
      this.$http.get('http://api.tianapi.com/txapi/ncov/index?key=104ede353793b6b5777b7d73061182ea').then(res => {
        if (res.status !== 200) {
          return this.$message.err('数据请求失败，请确认是否开启网络')
        }
        var notes = res.data.newslist[0]
        var note1 = notes.desc.note1
        var note2 = notes.desc.note2
        var note3 = notes.desc.note3
        var remark1 = notes.desc.remark1
        var remark2 = notes.desc.remark2
        var remark3 = notes.desc.remark3
        var remark4 = notes.desc.remark4
        var remark5 = notes.desc.remark5
        this.dataList.push(note1, note2, note3, remark1, remark2, remark3, remark4, remark5)
        this.dataList = this.dataList.filter(function (s) {
          return s && s.trim() // 注：IE9(不包含IE9)以下的版本没有trim()方法
        })
        for (var i = 0; i < this.dataList.length; i++) {
          var json = {
            index: i,
            tsxx: this.dataList[i]
          }
          this.zone.push(json)
        }
      })
    },
    ssxx () {
      this.$http.get('http://api.tianapi.com/txapi/ncov/index?key=104ede353793b6b5777b7d73061182ea').then(res => {
        if (res.status !== 200) {
          return this.$message.err('数据请求失败，请确认是否开启网络')
        }
        var news = res.data.newslist[0]
        var newsList = news.news
        this.newsList = newsList
        for (var j = 0; j < this.newsList.length; j++) {
          var newsListJson = {
            title: this.newsList[j].title,
            news: this.newsList[j].summary,
            infoSource: this.newsList[j].infoSource,
            pubDateStr: this.newsList[j].pubDateStr
          }
          this.newList1.push(newsListJson)
        }
      })
    }
  }
}
</script>

<style scoped>

</style>
